package com.yanqu.road.server.cmd.activity.travelbook;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.TravelBookProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.travelbook.TravelBookModule;
import com.yanqu.road.server.protocol.Protocol;

/**
 * @Author : Cxp
 * @Time : 2024-12-31
 * @Description : 更新引导
 */

@Cmd(code = Protocol.S_TRAVEL_BOOK_UPDATE_GUIDE_IDX, desc = "更新引导")
public class TravelBookUpdateGuideIdxCmd extends AbstractCommand {
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        TravelBookProto.TravelBookUpdateGuideIdxReq req =
                TravelBookProto.TravelBookUpdateGuideIdxReq.parseFrom(packet.getBytes());
        ret = player.getModule(TravelBookModule.class).updateGuideIdx(req.getGuideIdx());
    }

    @Override
    public void sendData(GamePlayer player) {
        if (ret != 0) {
            player.sendPacket(Protocol.U_TRAVEL_BOOK_UPDATE_GUIDE_IDX,
                    TravelBookProto.TravelBookUpdateGuideIdxResp.newBuilder().setRet(ret));
        }
    }
}
